<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/8/6
 * Time: 19:45
 */


//处理json字符中的特殊字符
function getJsonToArr($result, $return_array = true)
{
    $tempArr = NULL;
    $result = preg_replace('/([^\\\])(":)(\d{9,})(,")/i', '${1}${2}"${3}"${4}', $result); //taobao bug,number >2^32
    $tempArr = json_decode($result, $return_array);
    if ($tempArr == NULL) {
        $patterns = array('/,+\s*\}/', '/,+\s*\]/', '/"\s+|\s+"/', '/\n|\r|\t/', '/\\\/', '/ss+/');
        $replacements = array('}', ']', '"', ' ', '', ' ');
        $result = preg_replace($patterns, $replacements, $result);
        $tempArr = json_decode($result, $return_array);
    }

    return $tempArr;
}